package ys.ewp.dto;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import ys.ewp.po.Task;

public class TaskDto {
	//任务ID
	private Integer id;
	//任务名称
	private String taskName;
	//任务介绍
	private String taskContent;
	//任务规定完成时间
	private Date finishDate;
	//任务最终完成时间
	private Date finalDate;
	//任务派发者ID
	private Integer allotId;
	//任务等级ID
	private Integer levelId;
	//任务负责人
	private Integer principalId;
	//创建时间
	private Date dateCreated;
	//更新时间
	private Date dateUpdated;
	//删除标记
	private boolean deleted = false;
	//任务状态
	private Integer status;
	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getTaskName() {
		return taskName;
	}
	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}
	public String getTaskContent() {
		return taskContent;
	}
	public void setTaskContent(String taskContent) {
		this.taskContent = taskContent;
	}
	public Date getFinishDate() {
		return finishDate;
	}
	public void setFinishDate(Date finishDate) {
		this.finishDate = finishDate;
	}
	public Date getFinalDate() {
		return finalDate;
	}
	public void setFinalDate(Date finalDate) {
		this.finalDate = finalDate;
	}
	public Integer getAllotId() {
		return allotId;
	}
	public void setAllotId(Integer allotId) {
		this.allotId = allotId;
	}
	public Integer getLevelId() {
		return levelId;
	}
	public void setLevelId(Integer levelId) {
		this.levelId = levelId;
	}

	public Integer getPrincipalId() {
		return principalId;
	}
	public void setPrincipalId(Integer principalId) {
		this.principalId = principalId;
	}
	
	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateUpdated() {
		return dateUpdated;
	}

	public void setDateUpdated(Date dateUpdated) {
		this.dateUpdated = dateUpdated;
	}
	
	public boolean isDeleted() {
		return deleted;
	}
	
	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	
	
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	/**
	 * @功能 根据任务PO对象获得任务DTO对象
	 */
	public static TaskDto getDtoByPo(Task task){
		TaskDto taskDto = new TaskDto();
		taskDto.setId(task.getId());
		taskDto.setTaskName(task.getTaskName());
		taskDto.setTaskContent(task.getTaskContent());
		taskDto.setFinishDate(task.getFinishDate());
		taskDto.setFinalDate(task.getFinalDate());
		taskDto.setAllotId(task.getAllotEmployee().getId());
		taskDto.setLevelId(task.getTaskLevel().getId());
		taskDto.setPrincipalId(task.getPrincipal().getId());
		taskDto.setDateCreated(task.getDateCreated());
		taskDto.setDateUpdated(task.getDateUpdated());
		taskDto.setDeleted(task.isDeleted());
		return taskDto;
	}
	
	/**
	 * @功能 根据任务DTO对象获得任务PO对象
	 */
	public static Task getPoByDto(TaskDto taskDto){
		Task task = new Task();
		task.setId(taskDto.getId());
		task.setTaskName(taskDto.getTaskName());
		task.setTaskContent(taskDto.getTaskContent());
		task.setFinishDate(taskDto.getFinishDate());
		task.setFinalDate(taskDto.getFinalDate());
		task.setDateCreated(taskDto.getDateCreated());
		task.setDateUpdated(taskDto.getDateUpdated());
		task.setDeleted(taskDto.isDeleted());
		return task;
	}
	
	/**
	 * 	@功能 根据PO列表获取DTO列表
	 * @param taskList 
	 * @return 
	 */
	public static List<TaskDto> getDtoListByPoList(List<Task> taskList){
		if(taskList == null || taskList.isEmpty()){
			return Collections.emptyList();
		}
		List<TaskDto> taskDtoList = new ArrayList<TaskDto>();
		for(Task task : taskList){
			taskDtoList.add(getDtoByPo(task));
		}
		return taskDtoList;
	}
	/**
	 * @功能 根据DTO列表获取PO列表
	 * @param taskDtoList
	 * @return
	 */
	public static List<Task> getPoListByDtoList(List<TaskDto> taskDtoList){
		if(taskDtoList == null || taskDtoList.isEmpty()){
			return Collections.emptyList();
		}
		List<Task> taskList = new ArrayList<Task>();
		for(TaskDto taskDto : taskDtoList){
			taskList.add(getPoByDto(taskDto));
		}
		return taskList;
	}
}
